package com.sanqi.work.manager.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sanqi.work.domain.WorkScoreConf;
import com.sanqi.work.manager.IWorkScoreConfManager;
import com.sanqi.work.mapper.WorkScoreConfMapper;

import cn.hutool.core.util.StrUtil;

@Component
public class WorkScoreConfManager implements IWorkScoreConfManager{
    @Autowired
    private WorkScoreConfMapper workScoreConfMapper;
    
    @Override
    public WorkScoreConf getByCode(String confCode) {
        if(StrUtil.isBlank(confCode)) {
            return null;
        }
        LambdaQueryWrapper<WorkScoreConf> query = new LambdaQueryWrapper<>();
        query.eq(WorkScoreConf::getConfCode, confCode);
        return workScoreConfMapper.selectOne(query);
    }
    
    @Override
    public int countByCode(String confCode) {
        if(StrUtil.isBlank(confCode)) {
            return 0;
        }
        LambdaQueryWrapper<WorkScoreConf> query = new LambdaQueryWrapper<>();
        query.eq(WorkScoreConf::getConfCode, confCode);
        return workScoreConfMapper.selectCount(query).intValue();
    }
}
